package 牛客题霸;

public class 大数加法 {

    public static String solve (String s, String t) {
        if(s.length() <= 0) {
            return t;
        }
        if(t.length() <= 0) {
            return s;
        }
        int i = s.length() - 1;
        int j = t.length() - 1;
        int temp = 0;
        StringBuilder resultStr = new StringBuilder();
        while (i >= 0 || j >= 0 || temp != 0) {
            temp += i >= 0 ? s.charAt(i--) - '0' : 0;
            temp += j >= 0 ? t.charAt(j--) - '0': 0;
            resultStr.append(temp % 10);
            temp /= 10;
        }
        System.out.println(resultStr.toString());
        return resultStr.reverse().toString();
    }

    public static void main(String[] args) {
        String solve = solve("12121", "313");
        System.out.println(solve);
    }
}
